<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<head>
		<title>Cover Printer</title>
		<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
		<xf:model id="MediathekModel" xmlns="">
			<xf:instance id="MediathekInstance" src="Aufgabe5_tracks_finalize_output.xml">
			</xf:instance>
			
			<xf:instance id="SelectorInstance" xmlns="">
				<MyData>
					<ContainerSelector/>
					<SelectedAlbum/>
					<SelectedCompilation/>
					<AlbumTable/>
					<CompilationTable/>
					<SelectedCover/>
				</MyData>
			</xf:instance>
			
			<xf:instance id="AlbumInstance" xmlns="">
				<Album>
					<Name></Name>
					<Track></Track>
				</Album>
			</xf:instance>
			
			<xf:bind nodeset="instance('SelectorInstance')/SelectedAlbum" relevant="instance('SelectorInstance')/ContainerSelector = 1" />
			<xf:bind nodeset="instance('SelectorInstance')/SelectedCompilation" relevant="instance('SelectorInstance')/ContainerSelector = 2" />
			<xf:bind nodeset="instance('SelectorInstance')/AlbumTable" relevant="instance('SelectorInstance')/ContainerSelector = 1 and instance('SelectorInstance')/SelectedAlbum != ''" />
			<xf:bind nodeset="instance('SelectorInstance')/CompilationTable" relevant="instance('SelectorInstance')/ContainerSelector = 2 and instance('SelectorInstance')/SelectedCompilation != ''" />
			<xf:submission id="generateSVGSubmission" method="put" action="Album.xml" ref="instance('AlbumInstance')" indent="true"/>
			<xf:action ev:event="xforms-submit-done">
				<xf:load>
					<xf:resource value="instance('SelectorInstance')/SelectedCover" />
				</xf:load>
			</xf:action>
        </xf:model>
	</head>
	<body>
		
		<h1>Cover Printer</h1>
		
		<!-- Auswahl für Alben oder Compilations -->
		<xf:select1 id="CoverSelectorID" ref="instance('SelectorInstance')/SelectedCover">
			<xf:label>Bitte waehlen Sie aus welche Cover Version Sie drucken moechten: </xf:label>
			<xf:item>
				<xf:label>Cover 1</xf:label>
				<xf:value>http://localhost/xml-praktikum/showSVG.php?cover=svg/cover1.xslt</xf:value>
			</xf:item>
			<xf:item>
				<xf:label>Cover 2</xf:label>
				<xf:value>http://localhost/xml-praktikum/showSVG.php?cover=svg/cover2.xslt</xf:value>
			</xf:item>
			<xf:item>
				<xf:label>Cover 3</xf:label>
				<xf:value>http://localhost/xml-praktikum/showSVG.php?cover=svg/cover3.xslt</xf:value>
			</xf:item>
		</xf:select1>
		<br/>
		<br/>
		
		<!-- Auswahl für Alben oder Compilations -->
		<xf:select1 id="ContainerSelectorID" ref="instance('SelectorInstance')/ContainerSelector">
			<xf:label>Bitte waehlen Sie aus ob Sie ein Album oder eine Compilation drucken moechten: </xf:label>
				<xf:item>
					<xf:label>Album</xf:label>
					<xf:value>1</xf:value>
				</xf:item>
				<xf:item>
					<xf:label>Compilation</xf:label>
					<xf:value>2</xf:value>
				</xf:item>
		</xf:select1>
		<br/>
		<br/>

		<!-- Auswahl für Alben -->
		<xf:select1 id="AlbumSelectorID" ref="instance('SelectorInstance')/SelectedAlbum">
			<xf:label>Bitte waehlen Sie das gewuenschte Album aus: </xf:label>
			<xf:itemset nodeset="instance('MediathekInstance')/Albums/Album">
				<xf:label ref="./AlbumName"/>
				<xf:value ref="./AlbumUUID"/>
			</xf:itemset>
		</xf:select1>
		
		<!-- Auswahl für Compilations -->
		<xf:select1 id="CompilationSelectorID" ref="instance('SelectorInstance')/SelectedCompilation">
			<xf:label>Bitte waehlen Sie die gewuenschte Compilation aus: </xf:label>
			<xf:itemset nodeset="instance('MediathekInstance')/Compilations/Compilation">
				<xf:label ref="./CompilationName"/>
				<xf:value ref="./CompilationUUID"/>
			</xf:itemset>
		</xf:select1>
		<br/>
		<br/>
		
		<!-- Anzeigen der Tabelle mit den Tracks des Albums -->
		<xf:group ref="instance('SelectorInstance')/AlbumTable">
			<xf:repeat nodeset="instance('MediathekInstance')/TrackArea/Track[AlbumUUID=instance('SelectorInstance')/SelectedAlbum]">
				<p id="TrackNumber"># <xf:output ref="./TrackNumber"/></p>
				<p id="TrackArtist"><b>Artist:</b> <xf:output ref="./Artist"/></p>
				<p id="TrackName"><b>Name:</b> <xf:output ref="./Name"/></p>
				<p id="TrackComposer"><b>Composer:</b> <xf:output ref="./Composer"/></p>
			</xf:repeat>
			<br/>
			<xf:submit submission="generateSVGSubmission">
				<xf:label>Generieren des Ausdruckes</xf:label>
				<xf:action ev:event="DOMActivate">
					<xf:insert origin="instance('MediathekInstance')/Albums/Album[AlbumUUID=instance('SelectorInstance')/SelectedAlbum]/AlbumName/text()" nodeset="instance('AlbumInstance')/Name"/>
					<xf:insert origin="instance('MediathekInstance')/TrackArea/Track[AlbumUUID=instance('SelectorInstance')/SelectedAlbum]" nodeset="instance('AlbumInstance')/Track"/>
				</xf:action>
			</xf:submit>
		</xf:group>
		
		<!-- Anzeigen der Tabelle mit den Tracks der Compilation -->
		<xf:group ref="instance('SelectorInstance')/CompilationTable">
			<xf:repeat nodeset="instance('MediathekInstance')/TrackArea/Track[CompilationUUID=instance('SelectorInstance')/SelectedCompilation]">
				<div>
					<p id="TrackNumber"># <xf:output ref="./TrackNumber"/></p>
					<p id="TrackArtist"><b>Artist:</b> <xf:output ref="./Artist"/></p>
					<p id="TrackName"><b>Name:</b> <xf:output ref="./Name"/></p>
					<p id="TrackComposer"><b>Composer:</b> <xf:output ref="./Composer"/></p>
				</div>
			</xf:repeat>
			<br/>
			<xf:submit submission="generateSVGSubmission">
				<xf:label>Generieren des Ausdruckes</xf:label>
				<xf:action ev:event="DOMActivate">
					<xf:insert origin="instance('MediathekInstance')/Compilations/Compilation[CompilationUUID=instance('SelectorInstance')/SelectedCompilation]/CompilationName/text()" nodeset="instance('AlbumInstance')/Name"/>
					<xf:insert origin="instance('MediathekInstance')/TrackArea/Track[CompilationUUID=instance('SelectorInstance')/SelectedCompilation]" nodeset="instance('AlbumInstance')/Track"/>
				</xf:action>
			</xf:submit>
		</xf:group>
	</body>
</html>
